<template>
  <!-- 列表 -->
  <ContentWrap>
    <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
      <el-table-column label="收益序号" align="center" prop="id" >
        <template #default="scope">
          <el-link type="primary" @click="openForm('update', scope.row.id)">{{
            scope.row.id
          }}</el-link>
        </template>
      </el-table-column>
       <el-table-column label="年收益(元)" align="center" prop="annualEarnings" />
      <el-table-column label="填报人" align="center" prop="userId" />
      <el-table-column label="收益附件" align="center" prop="earningsFile" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="申报年份" align="center" prop="declareYear" />
      <el-table-column
        label="交费时间"
        align="center"
        prop="declareTime"
        :formatter="dateFormatter"
        width="180px"
      />

    </el-table>
  </ContentWrap>

  <EarningsForm ref="formRef" @success="getList" />

</template>
<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import { RentApi } from '@/api/zszx/rent'
import EarningsForm from '@/views/zszx/earnings/EarningsForm.vue'
const formRef = ref()
const openForm = (type: string, id?: number) => {
  formRef.value.open(type, id)
}


const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗

const props = defineProps<{
  rentId?: number // 合同序号（主表的关联字段）
}>()
const loading = ref(false) // 列表的加载中
const list = ref([]) // 列表的数据

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    list.value = await RentApi.getEarningsListByRentId(props.rentId)
  } finally {
    loading.value = false
  }
}

/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.pageNo = 1
  getList()
}

/** 初始化 **/
onMounted(() => {
  getList()
})
</script>